package cn.adelyn.base.api.snowfalke.feign;

import cn.adelyn.common.core.response.ServerResponseEntity;
import cn.adelyn.common.feign.config.FeignInsideAuthConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author chengze
 * @date 2022/9/8
 * @desc
 */
// name 用来标识服务，需要与 app.application.name 相同，不然 feign 找不到服务提供者
// contextId 用来标识 bean，若有多个 value 相同 但未用 contextId 标识的 bean 启动会报错
// https://blog.csdn.net/MyronCham/article/details/121419326?ops_request_misc=&request_id=&biz_id=102&utm_term=%20Invalid%20bean%20definition%20with%20&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-121419326.142^v71^one_line,201^v4^add_ask&spm=1018.2226.3001.4187
// feign 调用的 url 是 name + Getmapping 里的 value，如果服务配置了 server.servlet.context-path 那就填到 path 参数，作为feign请求的前缀，不然会报404
@FeignClient(name = "adelyn-base-snowflake", contextId = "Id")
public interface SnowflakeFeignClient {

    /**
     * 获取唯一id
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/snowflake/Id")
    ServerResponseEntity<Long> snowflakeId();
}
